package com.cpms.framework.common.core.caffeine;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.annotation.Order;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @description:
 * @author: gulang
 * @time: 2023/12/8
 */
@ConfigurationProperties(prefix = "caffeine" )
@Order(-1)
public class CaffeineProperty {
    private Map<String, PropConfig> caches;

    public Map<String, PropConfig> getCaches() {
        return caches;
    }

    public void setCaches(Map<String, PropConfig> caches) {
        this.caches = caches;
    }

    public static class PropConfig {
        /**
         * 最后一次写入或者访问后多久过期，每次访问过期时间会重新计算
         */
        private Long expireAfterAccess;
        /**
         * 最后一次写入后多久过期
         */
        private Long expireAfterWrite;

        /**
         * 常用配置值：DAYS、HOURS、MINUTES、SECONDS
         */
        private TimeUnit timeUnit;

        private Integer initCapacity;

        private Long maximumSize;

        public Long getExpireAfterAccess() {
            return expireAfterAccess;
        }


        public void setExpireAfterAccess(Long expireAfterAccess) {
            this.expireAfterAccess = expireAfterAccess;
        }

        public Long getExpireAfterWrite() {
            return expireAfterWrite;
        }

        public void setExpireAfterWrite(Long expireAfterWrite) {
            this.expireAfterWrite = expireAfterWrite;
        }

        public TimeUnit getTimeUnit() {
            return timeUnit;
        }

        public void setTimeUnit(TimeUnit timeUnit) {
            this.timeUnit = timeUnit;
        }

        public Integer getInitCapacity() {
            return initCapacity;
        }

        public void setInitCapacity(Integer initCapacity) {
            this.initCapacity = initCapacity;
        }

        public Long getMaximumSize() {
            return maximumSize;
        }

        public void setMaximumSize(Long maximumSize) {
            this.maximumSize = maximumSize;
        }
    }
}
